﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

public partial class role_add : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            CMSModel.Role role = new CMSModel.Role();
            role.RoleName = txtName.Text;
            if (Request["aa"] == "1")
            {
                role.IsEnable = true;
            }
            else
            {
                role.IsEnable = false;
            }
            CMSModel.CMSEntities cms = DBManager.GetCmsEmtity();
            cms.AddToRole(role);
            cms.SaveChanges();
            ClientScript.RegisterStartupScript(GetType(), "aa", "alert('添加成功'),document.location='Default.aspx'", true);
        }
        catch (Exception ex)
        {
            LogYuMin.LogWriter.GetWriter(LogYuMin.LogFile.error).Write(GetType(), "addRole", LogYuMin.LogStates.ERROR, ex);
            ClientScript.RegisterStartupScript(GetType(), "aa", "alert('添加失败')", true);
        }
    }
}